//
//  ModelWin.m
//  Exercise
//
//  Created by zhouxiaobo on 15/11/11.
//  Copyright © 2015年 mapath. All rights reserved.
//

#import "ModelWin.h"

@implementation ModelWin

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor purpleColor];
    
    _textField = [[UITextField alloc]init];
    _textField.frame = CGRectMake(screenWidth/2-80, 380, 160, 50);
    _textField.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:_textField];
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(screenWidth/2-80, 300, 160, 40)];
    btn.backgroundColor = [UIColor redColor];
    [btn setTitle:@"DisMiss" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(disMiss) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

- (void)disMiss {
    
    [self dismissViewControllerAnimated:YES completion:^{
        NSLog(@"窗口消失");
    }];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    //检查是否可以调通这个方法
    if ([self.delegate respondsToSelector:@selector(changeLableText:)]) {
        [_delegate changeLableText: _textField.text];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void) dealloc {
    NSLog(@"window is dead");
}

@end
